﻿using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE80;
using EnvDTE;

namespace TSVNAddin.Core
{
	public class SolutionAdapter : ISolutionExplorerItem
	{
		private readonly DTE2 _Dte;

		public SolutionAdapter(DTE2 dte)
		{
			_Dte = dte;
		}

		public virtual string GetFileName()
		{
			return _Dte.Solution.FileName;
		}

		public virtual bool IsOpen()
		{
			return _Dte.Solution.IsOpen;
		}

		ISolutionExplorerItem ISolutionExplorerItem.GetChildByName(string name)
		{
			foreach (Project project in _Dte.Solution.Projects)
			{
				if (project.Name == name)
					return new ProjectAdapter(project);
			}

			return null;
		}

		string ISolutionExplorerItem.GetPath()
		{
			return GetFileName();
		}
	}
}
